home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / Composite.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  4.1 KB  |  162 lines

  1. /*
  2. ** $VER: Composite.ieb 1.2, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten 
  5. ** 24/1 1997 Stockholm/Sweden
  6. **
  7. ** Composite two images into one with with various mix-functions.
  8. ** Use separate batch scripts for "Alpha" and "Mix" functions.
  9. */
  10.  
  11. options results
  12. signal on error
  13.  
  14. parse arg input command
  15. input = upper(strip(input))
  16. address 'IMAGEENGINEER'
  17.  
  18. select  /* Required batch script commands */
  19.   when input = 'INFO' then    return get_info()
  20.   when input = 'CONFIG' then  return get_config(command)
  21.   when input = 'PROCESS' then return process_image(command)
  22.   otherwise do
  23.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  24.     return '<ERROR>'
  25.   end
  26. end
  27.  
  28. exit 0
  29.  
  30. /* Required "Get_info" procedure  ------------------------------------ */
  31. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  32.  
  33. get_info:
  34.   back = 'OK S2'
  35. return back
  36.  
  37. /* Required "Get_config" procedure  ---------------------------------- */
  38.  
  39. get_config:
  40.   parse arg '"'command'"'
  41.   
  42.   Xoff=0 ; Yoff=0
  43.   
  44.   if command ~= '' then parse var command Xoff Yoff '#'CFunk
  45.  
  46.   'IE_TO_FRONT'
  47.  
  48.   form = 'FORM "Composite" " OK | Cancel"',
  49.   ' INTEGER,"X offset",-4096,4096,'Xoff',SLIDER',
  50.   ' INTEGER,"Y offset",-4096,4096,'Yoff',SLIDER'
  51.  
  52.   if command = '' then do  
  53.     form = form||' CYCLE,"Composite method","Add|Difference|Max|Min|Multiply|Subtract",0'
  54.     
  55.     form
  56.     parse var result ok Xoff Yoff CFunk
  57.     if ok = 0 then return '<ERROR>'
  58.  
  59.     select
  60.       when CFunk = 0 then CFunk = 'ADD'
  61.       when CFunk = 1 then CFunk = 'DIFFERENCE'
  62.       when CFunk = 2 then CFunk = 'MAX'
  63.       when CFunk = 3 then CFunk = 'MIN'
  64.       when CFunk = 4 then CFunk = 'MULTIPLY'
  65.       when CFunk = 5 then CFunk = 'SUBTRACT'
  66.     end
  67.   end
  68.   else do
  69.     form
  70.     parse var result ok Xoff Yoff
  71.     if ok = 0 then return '<ERROR>'
  72.  
  73.     CFunk = 'none'
  74.   end
  75.  
  76.   back = Xoff Yoff '#'CFunk
  77. return back
  78.  
  79. /* Required "Process_image" procedure  ------------------------------- */
  80.  
  81. process_image:
  82.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' '"'sec_image'"'
  83.   parse var options Xoff Yoff '#'CFunk
  84.  
  85.   'OPEN' '"'src_image'"' '24'
  86.   if (RC ~= 0) then do
  87.     'IE_TO_FRONT'
  88.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  89.     return '<ERROR>'
  90.   end
  91.   else LoadImage = Result
  92.  
  93.   if (strip(upper(src_image)) = strip(upper(sec_image))) then use_same = 1
  94.  
  95.   if use_same ~= 1 then do
  96.     'OPEN' '"'sec_image'"' '24'
  97.     if (RC ~= 0) then do
  98.       'IE_TO_FRONT'
  99.       'REQUEST' '"Failed to load image:' d2c(10)||sec_image'"' '" OK "'
  100.       return '<ERROR>'
  101.     end
  102.     else SecondImage = Result
  103.   end
  104.   else SecondImage = LoadImage
  105.  
  106.   'PROJECT_INFO' LoadImage 'WIDTH'
  107.   IW = RESULT
  108.   'PROJECT_INFO' LoadImage 'HEIGHT'
  109.   IH = RESULT
  110.  
  111.   'PROJECT_INFO' SecondImage 'WIDTH'
  112.   SIW = RESULT
  113.   'PROJECT_INFO' SecondImage 'HEIGHT'
  114.   SIH = RESULT
  115.  
  116.   if Xoff > SIW then Xoff = SIW
  117.   if Yoff > SIH then Yoff = SIH
  118.   
  119.   if Xoff < (-1)*IW then Xoff = (-1)*IW
  120.   if Yoff < (-1)*IH then Hoff = (-1)*IH
  121.   
  122.   'MARK' LoadImage 'PRIMARY'
  123.   'MARK' SecondImage 'SECONDARY'
  124.  
  125.   'COMPOSITE' Xoff Yoff CFunk
  126.   OutputImage = result
  127.   'CLOSE' LoadImage
  128.   if use_same ~= 1 then 'CLOSE' SecondImage
  129.  
  130.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  131.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  132.   if (RC ~= 0) then do
  133.     'IE_TO_FRONT'
  134.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  135.     return '<ERROR>'
  136.   end
  137.   'CLOSE' OutputImage
  138.  
  139.   back = 'OK'
  140. return back
  141.  
  142. /* Internal procedures  ---------------------------------------------- */
  143.  
  144. /*******************************************************************/
  145. /* This is where control goes when an error code is returned by IE */
  146. /* It puts up a message saying what happened and on which line     */
  147. /*******************************************************************/
  148.  
  149. error:
  150. if RC=5 then do
  151.     IE_TO_FRONT
  152.     LAST_ERROR
  153.     'REQUEST "'||RESULT||'"'
  154. end
  155. else do
  156.     IE_TO_FRONT
  157.     LAST_ERROR
  158.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  159. end
  160.  
  161. return '<ERROR>'
  162.